import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.*;
import javax.swing.border.EmptyBorder;


public class GoToJailUI extends JFrame {

	private JPanel contentPane;
	private Sound sound;

	/**
	 * Create the frame.
	 */
	public GoToJailUI() {
		setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
		setBounds(100, 100, 500, 510);
		contentPane =  new ImagePanel(new ImageIcon("Graphics/GoToJailUI.png").getImage());
		this.setTitle("Parak!");
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		
		
		ImageIcon exitPic = new ImageIcon("Graphics/ReturnToGame.png");
		ImageIcon exitPicOver = new ImageIcon("Graphics/ReturnToGameOver.png");
		JButton exitButton = new JButton(exitPic);
		
		contentPane.add(exitButton);
		
		exitButton.setBounds(400, 335, 62, 28);
		
		exitButton.setBorderPainted(false);
		exitButton.setContentAreaFilled(false);
		exitButton.setOpaque(false);
		exitButton.setRolloverEnabled(true);
		exitButton.setRolloverIcon(exitPicOver);
		exitButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitButtonPressed(evt);
            }
        });
		this.setVisible(true);
		SendCurrentPlayerToJailCommand send = new SendCurrentPlayerToJailCommand();
		send.execute();
		this.sound = new Sound();
		this.sound.playLoop("Sounds/parak.wav");
	}
	
	private void exitButtonPressed(java.awt.event.ActionEvent e){
		
		NextPlayerCommand nextPlayerCommand = new NextPlayerCommand();
		nextPlayerCommand.execute();
		this.dispose();
		this.sound.getClip().stop();
		
	}
}
